package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Position;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "岗位表")
public class PositionVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "岗位名称")
    private String name;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "状态：0禁用1启用")
    private Integer state;

    @ApiModelProperty(value = "管理岗：1、直接主管，2普通员工,3、其他管理类岗位")
    private Integer managementState;

    @ApiModelProperty(value = "岗位备注")
    private String remark;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Position convert(PositionVO vo) {
        Position entity = new Position();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Position> convertList(List<PositionVO> list) {
        List<Position> resultList = new ArrayList<>();
        for (PositionVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
